import 'package:share_fit/app/models/base_model.dart';
import 'package:share_fit/app/tools/date_tool.dart';

class TodayWeatherModel extends BaseModel {

  String? cityName;

  /// 预报日期
  /// 预报日期
  DateTime? date;

  /// 现在温度
  String? temp;

  /// 预报白天天气状况的图标代码，另请参考天气图标项目
  String? icon;

  ///  预报白天天气状况文字描述，包括阴晴雨雪等天气状态的描述
  String? text;

  /// 相对湿度，百分比数值
  String? humidity;

  /// 紫外线强度指数
  String? uvIndex;

  TodayWeatherModel({
    this.cityName,
    this.date,
    this.temp,
    this.icon,
    this.text,
    this.humidity,
    this.uvIndex,
  });

  @override
  bool from(Map map) {
    date = DateTool.getDateTimeFrom(map['dt']);
    temp = map['main']['temp'].toInt();
    text = map['weather'].last['description'];
    humidity = map['main']['humidity'].toDouble();
    return true;
  }

  @override
  toMap() {
    return {
      'cityName': cityName,
      'currentTemperature': temp,
      'unit': 0,
      // 'publishTime': (date?.microsecondsSinceEpoch / 1000000).truncate(),
      'phenomenon': text,
      'hum': humidity,
    };
  }

  @override
  // TODO: implement props
  List<Object?> get props => throw UnimplementedError();

  // @override
  // List<Object?> get props => [cityName, tempMax, tempMin, iconDay, textDay];

  // get tempRangeText => '$te${LocaleKeys.temperature_unit.ts} ~ $tempMax${LocaleKeys.temperature_unit.ts}';
  //
  // get dateWeekText {
  //   DateTime dt = DateTime.parse(fxDate!);
  //   String week = DateFormat('E', Get.locale?.languageCode).format(dt);
  //   return '$fxDate  $week';
  // }
  //
  // get weekDateText {
  //   DateTime dt = DateTime.parse(fxDate!);
  //   String week = DateFormat('E', Get.locale?.languageCode).format(dt);
  //   String date = DateFormat('MM-dd', Get.locale?.languageCode).format(dt);
  //   return ' $week  $date';
  // }
}
